#include "StdAfx.h"
#include ".\mencoderopts.h"
#include <string.h>
#define NULL 0





/*
*	list libavcodec's video codecs
*  The first column contains the codec names that should be passed after the vcodec config, like: -lavcopts vcodec=msmpeg4
*  An example with MJPEG compression: 
*  mencoder dvd://2 -o title2.avi -ovc lavc -lavcopts vcodec=mjpeg -oac copy
*/
FFMPEG_CODECS_ST builtin_ffvideo_codecs[] = {
	{ "mjpeg",	"Motion JPEG", }
	,
	{ "ljpeg", "lossless JPEG", }
	,
	{ "jpegls", "JPEG LS", }
	,
	{ "targa","targa image", }
	,
	{ "gif", "GIF image", }
	,
	{ "bmp","BMP image", }
	,
	{ "png", "PNG image,", }
	,
	{ "h261", "H.261", }
	,
	{ "h263", "H.263", }
	,
	{ "h263p", "H.263+", }
	,
	{ "mpeg4", "ISO standard MPEG-4(Divx, xvid compatible)", }
	,
	{ "msmpeg4", "pre-standard MPEG-4 variant by MS, v3(AKA DivX3)", }
	,
	{ "msmpeg4v2", "pre-standard MPEG-4 by MS, v2(used in old ASF files)",}
	,
	{ "wmv1", "Windows media video, version 1(AKA wmv7)", }
	,
	{ "wmv2", "windows media video version 2(AKA wmv8)", }
	,
	{ "rv10", "realvideo 1.0", }
	,
	{ "rv20", "realvideo 2.0", }
	,
	{ "mpeg1video", "MPEG-1 video",}
	,
	{ "mpeg2video", "MPEG-2 video", }
	,
	{ "huffyuv", "lossless compression",}
	,
	{ "ffvhuff", "ffmpeg modified huffyuv lossless",}
	,
	{ "asv1", "ASUS video v1", }
	,
	{ "asv2", "ASUS video v2", }
	,
	{ "ffv1", "FFmpeg's lossless video codec", }
	,
	{ "svq1", "sorenson video 1", }
	,
	{ "flv", "sorenson h.263 used in flash video",}
	,
	{ "flashsv", "flash screen video",}
	,
	{ "dvvideo", "sony digital video",}
	,
	{ "snow", "ffmpeg's experimental wavelet-based codec",}
	,
	{ "zbmv", "zip blocks motion video", }
	,
	{ NULL, NULL}
};

int  SUM_FFV_CODECS = sizeof(builtin_ffvideo_codecs)/sizeof(FFMPEG_CODECS_ST);


/*
*	list libavcodec's audio codecs
*  The first column contains the codec names that should be passed after the acodec option, like: -lavcopts acodec=ac3
*  An example with AC-3 compression: 
*  mencoder dvd://2 -o title2.avi -oac lavc -lavcopts acodec=ac3 -ovc copy
*/
FFMPEG_CODECS_ST builtin_ffaudio_codecs[] = {
	{ "ac3", "dolby digital ac-3", }
	,
	{ "adpcm_*", "adaptive pcm formats - see supplementary table"}
	,
	{ "flac", "free lossless audio codec flac"}
	,
	{ "g726", "g.726 adpcm"}
	,
	{ "libamr_nb", "3gpp adaptive multi-rate narrow-band"}
	,
	{ "libamr_wb", "3gpp adaptive multi-rate wide-band"}
	,
	{ "libfaac", "advanced audio coding(AAC)-using faac"}
	,
	{ "libgsm", "ETSI gsm 06.10 full rate"}
	,
	{ "libgsm_ms", "microsoft gsm"}
	,
	{ "libmp3lame", "mpeg-1 audio layer 3 -using LAME"}
	,
	{ "mp2", "MPEG-1 audio layer 2(MP2)"}
	,
	{ "pcm_*", "pcm formats - see supplementary table"}
	,
	{ "roq_dpcm", "ld software RoQ DPCM"}
	,
	{ "sonic", "experimental FFMPEG lossy codec"}
	,
	{ "sonics" "experimental ffmpeg lossless codec"}
	,
	{ "vorbis", "vorbis"}
	,
	{ "wmav1", "windows media audio v1"}
	,
	{ "wmav2", "windows media audio v2"}
};

int  SUM_FFA_CODECS = sizeof(builtin_ffaudio_codecs)/sizeof(FFMPEG_CODECS_ST);


/*
*	list all built in ovc
*/
OVC_CODECS_ST bulitin_ovc_codecs[] = {
	{
		"lavc", //ffmpeg
			"use one of libavcodec's video codecs",
			NULL,
	}
	,
	{
		"xvid", // campatible standard mpeg4 codec
			"Xvid, MPEG-4 Advanced Simple profile(ASP) coec",
			NULL,
	}
	,
	{
		"x264", 
			"x264", //MPEG-4 Advanced video coding(AVC), AKA h.264 codec,
			NULL,
	}
	,
	{
		"nuv",
			"nuppel video, used by some realtime applications",
			NULL,
	}
	,
	{
		"raw",
			"uncompressed video frames",
			NULL,
	}
	,
	{	
		"copy",
			"do not reencode, just copy compressed frames",
			NULL,
	}
	,
	{
		"frameno",
			"used for 3-pass encoding(not recommended)",
			NULL,
	}
	,
	{
		NULL, NULL, NULL
	}
};

int  SUM_OVC_CODECS = sizeof(bulitin_ovc_codecs)/sizeof(OVC_CODECS_ST);


/*
*	list all built in oac
*/
OAC_CODECS_ST bulitin_oac_codecs[] = {
	{
		"mp3lame",
			"encode to VBR, ABR or CBR MP3 with LAME",
			NULL,
	}
	,
	{
		"lavc",
			"use ofe of libavcodec's audio codecs",
			NULL,
	}
	,
	{
		"faac",
			"FAAC AAC audio encoder",
			NULL,
	}
	,
	{
		"toolame",
			"MPEG Audio layer 2 encoder",
			NULL,
	}
	,
	{
		"twolame",
			"MPEG audio layer 2 encoder based on tool LAME",
			NULL,
	}
	,
	{
		"pcm",
			"uncompressed PCM audio",
			NULL,
	}
	,
	{
		"copy",
			"do not reencode, just copy compressed frames",
			NULL,
	}
	,
	{
		NULL, NULL, NULL
	}
};

int SUM_OAC_CODECS = sizeof(bulitin_oac_codecs)/sizeof(OAC_CODECS_ST);


/*
*	list all containers supported by the version of MEncoder on your machine. The following choices are available: 
*  Example 13.1. encode to Macromedia Flash format
*  Creating a Macromedia Flash video suitable for playback in a web browser with the Macromedia Flash plugin: 
*	 mencoder input.avi -o output.flv -of lavf \
*			-oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc \
*			-lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3
*/
MENC_CONTAINERS_ST builtin_all_containers[] = {
	{ "lavf", "one of the containers supported by libavformat"}
	,
	{ "avi", "audio-video interleaved"}
	,
	{ "mpeg", "mpeg-1 and mpeg-2 ps"}
	,
	{ "rawvideo", "raw video stream(no muxing - one video stream only)"}
	,
	{ "rawaudio", "raw audio stream (no muxing - one audio stream only)"}
	,
		// below list all containers supported by libavforamt
	{ "mpeg", "mpeg-1 and mpeg-2 ps"}
	,
	{ "asf", "advanced stream format"}
	,
	{ "avi", "audio-video interleaved"}
	,
	{ "wav", "waveform audio"}
	,
	{ "swf", "macromedia flash"}
	,
	{ "flv", "macromedia flash video"}
	,
	{ "rm", "realmedia"}
	,
	{ "au", "SUN AU"}
	,
	{ "nut", "NUT open container (experimental and not yet spec-compliant)"}
	,
	{ "mov", "QuickTime"}
	,
	{ "mp4", "MPEG-4 format"}
	,
	{ "dv", "Sony digital video container"}
	,
	{ "mkv", "matroska open audio/video container"}
};

int SUM_ALL_CONTAINERS = sizeof(builtin_all_containers)/sizeof(MENC_CONTAINERS_ST);
char msg_audio_opts[512] = {0};

//////////////////////////////////////////////////////////////////////////
/*
 *	mencoder wrapper base class
 */
//////////////////////////////////////////////////////////////////////////
CMencoderopts::CMencoderopts(void)
{
	m_Pffvideo_codecs = NULL;
	m_Pffaudio_codecs = NULL;
	m_Povc_codecs = NULL;
	m_Poac_codecs = NULL;
	m_menc_containers = NULL;
}

CMencoderopts::~CMencoderopts(void)
{

}



const char *CMencoderopts::get_ffvideo_codecs(const char *v_name, const int index)
{
	int sum = 0;
	char *iterate = NULL;
	do {
		iterate = builtin_ffvideo_codecs[sum++].avc_codecs;
		if (strcmp(iterate, v_name) == 0) {
			return iterate;
		}
	}
	while(!iterate);

	return NULL;
}

const char *CMencoderopts::get_ffaudio_codecs(const char *a_name, const int index)
{
	int sum = 0;
	return NULL;

}

const char *CMencoderopts::get_ovc_codecs(const char *ovc_name, const int index)
{
	int sum = 0;
	return NULL;

}

const char *CMencoderopts::get_oac_codcecs(const char *oac_name, const int index)
{
	int sum = 0;
	return NULL;

}

const char *CMencoderopts::get_menc_containers(const char *containers, const int index)
{
	int sum = 0;
	return NULL;

}


/*
*	get sum support codecs or containers
*/
int CMencoderopts::get_sum_ffv() const
{
	return SUM_FFV_CODECS;
}

int CMencoderopts::get_sum_ffa() const
{
	return SUM_FFA_CODECS;
}

int CMencoderopts::get_sum_ovc() const
{
	return SUM_OVC_CODECS;
}

int CMencoderopts::get_sum_oac() const
{
	return SUM_OAC_CODECS;
}

int CMencoderopts::get_sum_container() const
{
	return SUM_ALL_CONTAINERS;
}

